<div id="content">
    <div class="row s_page_title">
        <sa-big-breadcrumbs [items]="['环卫管理','系统管理','小区RFID关联']" icon="fa-lg fa-cube" class="col-xs-12 col-sm-7 col-md-7 col-lg-4"></sa-big-breadcrumbs>
    </div>
    <sa-widgets-grid>
        <div class="s_table">
            <div sa-widget [editbutton]="false" color="darken" class="clearfix">
                <header><span class="widget-icon"> <i class="fa fa-table"></i> </span>
                    <h2>小区RFID关联</h2>
                </header>
                <div>
                    <div class="widget-body no-padding">
                        <div class="page-header clearfix s_table_opreation">
                            <div class="left page-header-btn">
                                <button type="button" class="btn btn-primary" (click)="newCompany(companyModal)">添加</button>
                                <button  type="button"  class="btn btn-primary" (click)="showImportModal(weightModal)">导入Excel文件</button>
                            </div>
                            <div class="right top-search">
                                <input type="text" [(ngModel)]="searchKey" (change)="table_search()" class="search-input" placeholder="RFID/小区名称/省/市/区">
                                <span class="top-search-box">
                                    <button class="top-search-btn" type="button" (click)="table_search()"> <i class="fa fa-search"></i></button>
                                </span>
                            </div>
                        </div>
                        <div class="table_scroll">
                            <table class="display dataTables responsive table table-striped table-bordered table-hover dataTable s_h5_table">
                                <thead>
                                    <tr>
                                        <th>RFID</th>
                                        <th>小区名称</th>
                                        <th>地址</th>
                                        <th>是否启用</th>
                                        <th>创建时间</th>
                                        <th>更新时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr *ngFor="let row of tableData">
                                        <td>{{row.rfid}}</td>
                                        <td>{{row.communityName}}</td>
                                        <td>{{row.provinceName}}/{{row.cityName}}/{{row.areaName}}</td>
                                        <td>{{row.isEnable?"是":"否"}}</td>
                                        <td>{{row.createTime}}</td>
                                        <td>{{row.updateTime}}</td>
                                        <td>
                                            <button type="button" (click)="editCompany(row,companyModal)">编辑</button>
                                            <button type="button" (click)="deleteCompany(row)">删除</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="table-fix clearfix">
                            <paginator [totalRecords]="totalCount" [rows]="pageSize" [currentPage]="curPage - 1" (onPageChange)="paginate($event)">
                            </paginator>
                            <button type="button" class="btn default refresh_btn" (click)="refresh()"><i class="fa fa-refresh"></i></button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </sa-widgets-grid>
</div>

<!-- 新增编辑用户类型   弹窗-->
<section bsModal #companyModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" (click)="companyClose(companyModal)" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"><span *ngIf="formType == 'new'">新增</span><span *ngIf="formType == 'update'">编辑</span>小区RFID配置</h4>
            </div>
            <form id="RFIDForm" role="form" novalidate="novalidate" [saBootstrapValidator]="validatorOptions">
                <div class="row form-horizontal" style="margin-top: 20px;">
                    <div class="form-group col-xs-12">
                        <label class="col-xs-3 control-label">RFID<sup>*</sup></label>
                        <div class="col-xs-9">
                            <input class="form-control" type="text" [(ngModel)]='RFIDForm.rfid' name='rfid' placeholder="RFID" />
                        </div>
                    </div>
                    <div class="form-group col-xs-12">
                        <label class="col-xs-3 control-label">小区名称<sup>*</sup></label>
                        <div class="col-xs-9">
                            <input class="form-control" type="text" [(ngModel)]='RFIDForm.communityName' name='communityName' placeholder="小区名称" />
                        </div>
                    </div>
                    <div class="form-group col-xs-12">
                        <label class="control-label col-xs-3">省份<sup>*</sup></label>
                        <div class="col-xs-9">
                            <div class="clearfix">
                                <select  class="form-control"  [(ngModel)]='RFIDForm.provinceId' (change)="provinceChange($event.target.value)" name="provinceId" placeholder="请选择" autocomplete='address-level1'>
                                    <option value="">请选择</option>
                                    <option  *ngFor="let item of provinceNameArr" [value]="item.id">{{item.areaName}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
    
                    <div class="form-group col-xs-12">
                        <label class="control-label col-xs-3">城市<sup>*</sup></label>
                        <div class="col-xs-9">
                            <div class="clearfix">
                                <select  class="form-control"  [(ngModel)]='RFIDForm.cityId' (change)="cityChange($event.target.value)" name="cityId" placeholder="请选择" autocomplete='address-level2'>
                                    <option value="">请选择</option>
                                    <option  *ngFor="let item of cityNameArr" [value]="item.id">{{item.areaName}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
    
                    <div class="form-group col-xs-12">
                        <label class="control-label col-xs-3">市区<sup>*</sup></label>
                        <div class="col-xs-9">
                            <div class="clearfix">
                                <select  class="form-control"  [(ngModel)]='RFIDForm.areaId' (change)="townChange($event.target.value)" name="areaId" placeholder="请选择" autocomplete='address-level3'>
                                    <option value="">请选择</option>
                                    <option  *ngFor="let item of townNameArr" [value]="item.id">{{item.areaName}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="form-group col-xs-12">
                        <label class="control-label col-sm-3 no-padding-right">是否启用<sup>*</sup></label>
                        <div class="col-sm-9">
                            <button class="isCommon" (click)="isEnableChange('1')" [ngClass]="RFIDForm.isEnable=='1'?'active':''">是</button>
                            <button class="isCommon" (click)="isEnableChange('0')" [ngClass]="RFIDForm.isEnable=='0'?'active':''">否</button>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" (click)="companyClose(companyModal)">取消</button>
                    <button type="button" class="btn btn-primary" (click)="companySubmit(companyModal)">确认</button>
                </div>
            </form>
        </div>
    </div>
</section>
<!-- 新增编辑用户类型 弹窗end-->
<!-- 导入弹框 -->
<div bsModal #weightModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
	aria-hidden="true">
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" (click)="cancelUp(weightModal)" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title">上传Excel文件</h4>
			</div>
			<div class="modal-body">

				<div class="row">
					<form class="form form-inline " role="form">
						<div class="row">
							<!--<label class="control-label col-sm-1" for="imgFile" style="padding: 0;display: inline-block;line-height: 32px;">文件</label>-->
							<div class="col-sm-10" style="padding: 0;">
								<div class="clearfix module_line">
									<button type="button" class="btn btn-primary" style="width: 120px;">上传模板文件
										<input type="file" class="up" (change)="fileChange($event.target.files)"
											name="fileToUpload" (click)='clearFile()' [(ngModel)]='fileUp' type="file"
											placeholder='' />
									</button>
									<span class="row" class="note">注：格式excel</span>
								</div>
							</div>
						</div>
						<div *ngIf="fileToUpload">
							<label class="control-label col-sm-1"></label>
							<div>
								<ul>
									<li class="file_list"><i class="fa fa-file-text-o"
											style="margin-right: 12px;"></i>{{fileToUpload.name}}<i
											class="fa fa-check-circle green" style="margin-left: 60px;"></i></li>
								</ul>
							</div>
						</div>
					</form>
				</div>

			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" (click)="cancelUp(weightModal)">取消</button>
				<button type="button" class="btn btn-primary" (click)="submitData(weightModal)">确认</button>
			</div>
		</div>
	</div>
</div>
<!-- 导入弹框 结束 -->